<template>
	<om-formsub-outer :index="index" :checkedit="checkedit">
		<om-autoform ref="autoform" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {buildSubFormData, subOnLoad, changeEditor,configSelectData,hasValue} from '../../../static/js/formUtil.js';
	import { ignoreHtml,ptFloat,minusF,getDateStr} from '@/static/js/common.js';
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return buildSubFormData({
				exists:"",
				initValue:{
					fileList:[]
				}
			})
		},
				
	
		methods:{
			initLoad(list){
				let _that = this
				_that.om.request(
					'tsysdict/findChildrenByCodeNoIsdel1',
					{
						code:'38024',
						lList:_that.exists
					}
				).then(res=>{
					_that.$refs.autoform.changeEditor('title3','fileTypeId','data',configSelectData(res,'id','dicname'))				
					_that.$refs.autoform.initSelectIndex('title3','fileTypeId')
				})
				
			}
		},
		onShow() {
			
		},
		onLoad(e) {
			let _that = this
			subOnLoad(_that, e, function() {
			if(e.configDataCacheKey){
				 _that.exists = _that.datas.filter((e,i)=>{
					return (i != _that.index)
				}).map(e=>e.fileTypeId).join(",")
				uni.getStorage({
					key: e.configDataCacheKey,
					success: function(res) {
						if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
							_that.autoformdata = res.data
							Object.assign(_that.initValue, _that.formdata)
							_that.autoformdata[0].order = _that.order
							changeEditor(_that.autoformdata[0].editors, "fileList", "fileSaveNameField", "fileSaveName")
							changeEditor(_that.autoformdata[0].editors, "fileList", "uploadUrl", "tsupplierInfoConfirm/uploadFile.do?id=1")
							// changeEditor(_that.autoformdata[0].editors, "fileUpload", "removeUrl", "tkeyWorkReport/removeInterimFile")
							changeEditor(_that.autoformdata[0].editors, "fileList", "loadUrl", "tsupplierInfoConfirm/getInterimFile")
							if(_that.formdata.fileList) {
								var tempFileList = []
								var fileUrlList = _that.formdata.fileList.map(t=>{
									tempFileList.push(t.fileSaveName)
									return t.fileSaveName
								})
								changeEditor(_that.autoformdata[0].editors, "fileList", "fileUrlList", fileUrlList)
								changeEditor(_that.autoformdata[0].editors, "fileList", "tempFileList", tempFileList)
							}
								_that.initLoad(e.lList)
							}
						}
					})
				}
							
			})
		}
	}
</script>

<style>
</style>

